#include <QGraphicsScene>  //场景
#include <QGraphicsView>   //摄像机
#include <QApplication>
#include <QIcon>
#include <GameSetting.h>
#include "player.h"
#include "score.h"
#include "health.h"
#include <QtMultimedia>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    a.setApplicationDisplayName("飞机大战");
    QApplication::setWindowIcon(QIcon(":/images/Sprites/hero/fly/hero1.png"));//设置头标

    //创建Player
    Player* player=new Player;

    //创建场景
    QGraphicsScene* scene=new QGraphicsScene;
    scene->addItem(player); //将玩家飞机添加进来
    scene->setSceneRect(0,0,GameSetting::SceneWidth
                        ,GameSetting::SceneHeight);
    scene->setBackgroundBrush(QImage(":/images/Sprites/image/background.png"));//设置背景板
    //创建分数文字
    scene->addItem(&Score::getInstance());
    //创建健康值文字
    scene->addItem(&Health::getInstance());
    //不会在点击时，取消player的facus状态
    scene->setStickyFocus(true);

    QGraphicsView view(scene);
    view.setFixedSize(GameSetting::SceneWidth
                     ,GameSetting::SceneHeight);
    view.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); //去除滚轮条
    view.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);  //去除滚轮条
    view.show();

    //添加背景音乐
    QMediaPlayer bgMusic;;
    QAudioOutput audioOutput;
    bgMusic.setAudioOutput(&audioOutput);
    bgMusic.setSource(QUrl("qrc:/images/Sprites/sounds/backMusic.mp3"));
    bgMusic.play();

    return a.exec();
}
